<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/common/commonConfig.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>

<head>
	<base href="<%=basePath%>">
	<title>更新单位详细</title>
	<script src="<%=basePath%>component/layout.js"></script>
    <script src="<%=basePath%>component/toolbar.js"></script>
	<script src="<%=basePath%>js/validateJS.js"></script>
	<script src="<%=basePath%>js/tableForm.js"></script>
</head>

<body onload="bodyInit()">
	<div id="dataObj">
	<div id="displayDiv" class="formlayout" style="width:100%;height:100%;overflow: auto;">
		<form action="<%=basePath%>system-unit/UnitAction!unitInfoEdit.action" method="post" name="editForm">
			<input type="hidden" name="tunitinfo.id" id="tunitinfo.id" value="${unitInfoEdit.id }"/>
			<input type="hidden" name="tunitinfo.unitId" id="tunitinfo.unitId" value="${unitInfoEdit.unitId }"/>  
			<table class="inputTable">
				<tr>
					<th>单位简称 </th>
					<td >
						${unitInfoEdit.unitShortenedForm }
						<input type="hidden" name="editFormHidden"
						 value="[{type:'input',id:'tunitinfo.unitShortenedForm',name:'tunitinfo.unitShortenedForm',value:'${unitInfoEdit.unitShortenedForm }',showText:'${unitInfoEdit.unitShortenedForm }',maxlength:'25'}]"/>
					</td>
				</tr>
				<tr>
					<th>单位邮箱</th>
					<td >
					${unitInfoEdit.unitEmail }
					<input type="hidden" name="editFormHidden"
					 value="[{type:'input',id:'tunitinfo.unitEmail',name:'tunitinfo.unitEmail',value:'${unitInfoEdit.unitEmail }',showText:'${unitInfoEdit.unitEmail }',maxlength:'25'}]"/>
					</td>
				</tr>
				<tr>
					<th>单位电话</th>
					<td >
					${unitInfoEdit.unitPhone }
					<input type="hidden" name="editFormHidden"
					 value="[{type:'input',id:'tunitinfo.unitPhone',name:'tunitinfo.unitPhone',value:'${unitInfoEdit.unitPhone }',showText:'${unitInfoEdit.unitPhone }',maxlength:'15'}]"/>
						
					</td>
				</tr>
				<tr>
					<th>单位地址</th>
					<td >
					${unitInfoEdit.unitAddress }
					<input type="hidden" name="editFormHidden"
					 value="[{type:'input',id:'tunitinfo.unitAddress',name:'tunitinfo.unitAddress',value:'${unitInfoEdit.unitAddress }',showText:'${unitInfoEdit.unitAddress }',maxlength:'25'}]"/>
						
					</td>
				</tr>
				<tr>
					<th>单位邮编</th>
					<td >
					${unitInfoEdit.unitPost }
					<input type="hidden" name="editFormHidden"
					 value="[{type:'input',id:'tunitinfo.unitPost',name:'tunitinfo.unitPost',value:'${unitInfoEdit.unitPost }',showText:'${unitInfoEdit.unitPost }',maxlength:'15'}]"/>
						
					</td>
				</tr>
				<tr>
					<th>单位职责</th>
					<td >
					${unitInfoEdit.undertakeWork }
					<input type="hidden" name="editFormHidden"
					 value="[{type:'textarea',id:'tunitinfo.undertakeWork',name:'tunitinfo.undertakeWork',value:'${unitInfoEdit.undertakeWork }',showText:'${unitInfoEdit.undertakeWork }'}]"/>				
					</td>
				</tr>
			</table>
		</form>
	</div>

	<div id="delDiv" style="display:none"><!-- 删除信息 -->
		<form action="<%=basePath%>system-unit/UnitAction!unitInfoEditClear.action" method="post" name="clearForm">
			<input type="hidden" name="tunitinfo.id" id="tunitinfo.id" value="${unitInfoEdit.id }"/>
			<input type="hidden" name="tunitinfo.unitId" id="tunitinfo.unitId" value="${unitInfoEdit.unitId }"/>
		</form>
	</div>
	</div>
</body>

<script type="text/javascript">
var dhxLayout = createLayoutNormal('1C',false,true);

function bodyInit(){
	configLayout();
}

function configLayout(){
	var a = dhxLayout.cells('a');
	a.hideHeader();
	a.setText('主页面');
	a.fixSize(true, true);
	if(power.getPower() != '' && power.getPowerDelete())
		createToolbarFromDHXLayoutCell(a,function(toolbar){
		    toolbar.addText("info", 1, "操作:");
		    toolbar.addSeparator("sep1", 2);
		    if(power.getPowerUpdate()){
		    	toolbar.addButton("update", 4, "修改", "settings.gif", "settings.gif");
		    	toolbar.addButton("forUpdate", 6, "提交", "save.gif", "save_dis.gif");
		    	toolbar.addButton("cancel", 7, "取消", "undo.gif", "undo_dis.gif");
		    	toolbar.hideItem('forUpdate');
		    	toolbar.hideItem('cancel');
		    }
    		if(power.getPowerDelete())toolbar.addButton("delete", 8, "删除", "cut.gif", "cut_dis.gif");
		    toolbar.attachEvent("onClick", function(id) {
		    	if(id == 'delete'){
		    		validateDel();
		    	}
		    	if(id == 'update'){
		    		//updateUnit();
		    		tableForm.tableToForm();
		    		toolbar.showItem('forUpdate');
		    		toolbar.showItem('cancel');
		    		toolbar.hideItem('update');
		    		
		    	}
		    	if(id == 'cancel'){
		    		tableForm.formReturnTable();
		    		toolbar.hideItem('forUpdate');
		    		toolbar.hideItem('cancel');
		    		toolbar.showItem('update');
		    	}
		    	if(id == 'forUpdate'){
		    		validateEdit();
		    	}
		    });
		});
	a.attachObject('dataObj');
}

function validateEdit(){
	
	var shortName = document.getElementById('tunitinfo.unitShortenedForm').value;
	if (shortName != '' && !validatePattern.validateInputZZ(shortName,false)){
		parent.parent.parent.notifyWarn('单位简称非法，输入只能是[汉字,数字、26个英文字母或者下划线]');
		return ;
	}

	var email = document.getElementById('tunitinfo.unitEmail').value;
	if (email != '' && !validatePattern.validateEmail(email,false)){
		parent.parent.parent.notifyWarn('单位邮箱非法');
		return ;
	}

	var phone = document.getElementById('tunitinfo.unitPhone').value;
	if (phone != '' && !validatePattern.validatePhone(phone,false)){
		parent.parent.parent.notifyWarn('单位电话非法');
		return ;
	}

	var address = document.getElementById('tunitinfo.unitAddress').value;
	if (address != '' && !validatePattern.validateInputZZ(address,false)){
		parent.parent.parent.notifyWarn('单位地址非法，输入只能是[汉字,数字、26个英文字母或者下划线]');
		return ;
	}

	var post = document.getElementById('tunitinfo.unitPost').value;
	if (post != '' && !validatePattern.validateZip(post,false)){
		parent.parent.parent.notifyWarn('单位邮编非法');
		return ;
	}
	layoutProgressOn(dhxLayout);
	document.forms["editForm"].submit();
}

function validateDel(){
	confirmInfo('确认删除单位详细信息',
		function(choose){
			if('ok' == choose){
				layoutProgressOn(dhxLayout);
				document.forms["clearForm"].submit();
			}else{
				return;
			}
		}
	);
}

function updateUnitInfo(){
	tableForm.tableToForm();
	document.getElementById('submitOperate').style.display='';
	document.getElementById('normalOperate').style.display='none';
}

function cancel(){
	tableForm.formReturnTable();
	document.getElementById('submitOperate').style.display='none';
	document.getElementById('normalOperate').style.display='';
}
</script>
	
</html>
